#!/usr/bin/env python3

import os


def walkfiles(dirpath):
    fileList = os.listdir(dirpath)
    dirs = []

    for i in fileList:
        fileName = os.path.join(dirpath, i)
        if os.path.isdir(fileName):
            dirs.append(fileName)
        else:
            yield fileName

    for i in dirs:
        g = walkfiles(i)
        for j in g:
            yield j


path = input('please input search path:')
pyfiles = [f for f in walkfiles(path) if f.endswith('.py')]

print(pyfiles)
print(len(pyfiles))
